﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;

namespace Arch.Common.IoC
{
    public static class ServiceLocatorExtensions
    {
        public static void BuildUp(this IServiceLocator serviceLocator, object instance)
        {
            if (serviceLocator is ArchUnityServiceLocator)
            {
                (serviceLocator as ArchUnityServiceLocator).Container.BuildUp(instance.GetType(), instance);
            }
            //TODO:manage MEF
        }

        public static void BuildUp<T>(this IServiceLocator serviceLocator, T instance)
        {
            if (serviceLocator is ArchUnityServiceLocator)
            {
                (serviceLocator as ArchUnityServiceLocator).Container.BuildUp(instance);
            }
            //TODO:manage MEF
        }
    }
}
